﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AnesSystem.Models;

namespace AnesSystem
{
    public class OperationData
    {
        #region Variables
        private VitalSignDataCache _vitalSignDataCache;
        private DrugsDataCache _drugsDataCache;
        private EventDataCache _eventDataCache;
        private Dictionary<string, VitalSignDataCache> _vitalSignDataCacheDic;
        private Dictionary<string, EventDataCache> _eventDataCacheDic;

        #endregion

        #region Constructor
        public OperationData(PatientLinkModel p)
        {
           
            InitEventCache();
            InitVitalCache(p);
            _drugsDataCache = new DrugsDataCache(p);
        }

      



        #endregion


        #region Properties
        public VitalSignDataCache VitalSignDataCache
        {
            get
            {
                return VitalSignDataCacheDic[DataManager.Instance.IsInAorP];
            }

            set
            {
                _vitalSignDataCache = value;
            }
        }

        public DrugsDataCache DrugsDataCache
        {
            get
            {
                //_drugsDataCache.DbSearch();
                return _drugsDataCache;
            }

            set
            {
                _drugsDataCache = value;
            }
        }

        public EventDataCache EventDataCache
        {
            get
            {
                return EventDataCacheDic[DataManager.Instance.IsInAorP];
            }

            set
            {
                _eventDataCache = value;
            }
        }

        public Dictionary<string, VitalSignDataCache> VitalSignDataCacheDic
        {
            get
            {
                return _vitalSignDataCacheDic;
            }

            set
            {
                _vitalSignDataCacheDic = value;
            }
        }

        public Dictionary<string, EventDataCache> EventDataCacheDic
        {
            get
            {
                return _eventDataCacheDic;
            }

            set
            {
                _eventDataCacheDic = value;
            }
        }



        #endregion


        #region 依赖属性


        #endregion


        #region Event


        #endregion


        #region PrivateMethods
        private void InitVitalCache(PatientLinkModel p)
        {
            VitalSignDataCacheDic = new Dictionary<string, VitalSignDataCache>();

            VitalSignDataCache anesVitalSignCache = new AnesVitalSignDataCache(EventDataCacheDic[Constants.ISANES],p.Id.ToString());
            VitalSignDataCacheDic.Add(Constants.ISANES, anesVitalSignCache);

            VitalSignDataCache pacuVitalSignCache = new PacuVitalSignDataCache(EventDataCacheDic[Constants.ISPACU], p.Id.ToString());
            VitalSignDataCacheDic.Add(Constants.ISPACU, pacuVitalSignCache);
           
        }
        private void InitEventCache()
        {
            EventDataCacheDic = new Dictionary<string, EventDataCache>();

            EventDataCache anesEventCache = new AnesEventDataCache();
            EventDataCacheDic.Add(Constants.ISANES, anesEventCache);

            EventDataCache pacuEventCache = new PacuEventDataCache();
            EventDataCacheDic.Add(Constants.ISPACU, pacuEventCache);

        }

        #endregion


        #region Public/ProtectedMethods
       

        #endregion


        #region EventHandlers


        #endregion
    }
}
